<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">打开新窗口</button>
    <button id="btn1">关闭窗口</button>
</body>
<script>
    //打开新窗口 window.open(网址:url/本地的相对路径)
    //关闭窗口 window.close()
    //name features replace可选属性
    var btn = document.getElementById("btn");
    var btn1 = document.getElementById("btn1");
    var newWindow;
    btn.onclick = function(){
        newWindow = window.open("http://www.baidu.com/","test","width=400px,height=400px");
    }
    //blank
    btn1.onclick = function(){
        newWindow.close();
    }

</script>
</html>